package com.buba.personnel.controller;

import com.buba.personnel.dao.OrganizationDao;
import com.buba.personnel.service.OrganizationService;
import com.buba.pojo.Message;
import com.buba.pojo.Organization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class OrganizationController {
    @Autowired
    private OrganizationService organizationService;
    /**
     * 查询机构
     * @return
     */
    @RequestMapping("/selOrganization")
    public List<Organization> selOrganization(@RequestParam Map<String,Object> paramMap){
        return  organizationService.selOrganization(paramMap);

    }

    /**
     * 删除
     */
    @RequestMapping("/delOrganization")
    public Message delOrganization(Integer id){
        long count = organizationService.delOrganization(id);
        return new Message(1,"删除了"+ count +"条数据 ");
    }

    /**
     * 添加机构
     * @param organization
     * @return
     */
    @RequestMapping("/addOrganization")
    public Message addOrganization(Organization organization){
        long count = organizationService.addOrganization(organization);
        return new Message(1,"添加了"+ count +"条数据 ");
    }

    /**
     * 修改机构信息
     * @param organization
     * @return
     */
    @RequestMapping("/updOrganization")
    public Message updOrganization(Organization organization){
        long count = organizationService.updOrganization(organization);
        return new Message(1,"修改了"+ count +"条数据 ");
    }
}
